mongo-delete.js ➔ ???   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 28
rs 8.8571
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A mongo-delete.js ➔ ... ➔ ??? 0 3 1
1
const {MongoClient} = require('mongodb');
2
3
MongoClient.connect('mongodb://localhost:27017/JokesApp', (err, db) => {
4
    if (err){
5
        return console.log('failed to connect to mongodb server. ', err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
6
    }
7
8
    console.log('Connected to MongoDB Server');
9
10
    //deleteMany - delete all the occcurences
11
    db.collection('Jokes').deleteMany({joke : 'Sample joke 2'}).then((result) => {
12
        console.log(result.result);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
13
    }, (err) => {
14
        cosole.log('Error deleting many. E : ', err)
0 ignored issues
show
Bug introduced by
The variable cosole seems to be never declared. If this is a global, consider adding a /** global: cosole */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
15
    });
16
17
    //deleteOne - deletes only first occurence of all the occurences
18
    db.collection('Jokes').deleteOne({joke : 'Test 1'}).then((result) => {
19
        console.log(result.result);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
20
    });
21
22
    db.collection('Jokes').findOneAndDelete({joke : 'Test 2'}).then((doc) => {
23
        console.log(doc);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
24
    }, (err) => {
25
        console.log('Error find one and delete. E: ', err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
26
    });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
27
28
    //close the DB
29
    // db.close();
30
});